.class public final Lorg/jboss/netty/util/UnsafeDetectUtil;
.super Ljava/lang/Object;
.source "UnsafeDetectUtil.java"


# static fields
.field private static final THE_UNSAFE:Ljava/lang/String; = "theUnsafe"

.field private static final UNSAFE:Ljava/lang/String; = "sun.misc.Unsafe"

.field private static final UNSAFE_FOUND:Z


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 33
    const-class v0, Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-virtual {v0}, Ljava/lang/Class;->getClassLoader()Ljava/lang/ClassLoader;

    move-result-object v0

    invoke-static {v0}, Lorg/jboss/netty/util/UnsafeDetectUtil;->isUnsafeFound(Ljava/lang/ClassLoader;)Z

    move-result v0

    sput-boolean v0, Lorg/jboss/netty/util/UnsafeDetectUtil;->UNSAFE_FOUND:Z

    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 61
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 63
    return-void
.end method

.method private static hasUnsafeField(Ljava/lang/Class;)Z
    .locals 1
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/Class",
            "<*>;)Z"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/PrivilegedActionException;
        }
    .end annotation

    .prologue
    .line 49
    .local p0, unsafeClass:Ljava/lang/Class;,"Ljava/lang/Class<*>;"
    new-instance v0, Lorg/jboss/netty/util/UnsafeDetectUtil$1;

    invoke-direct {v0, p0}, Lorg/jboss/netty/util/UnsafeDetectUtil$1;-><init>(Ljava/lang/Class;)V

    invoke-static {v0}, Ljava/security/AccessController;->doPrivileged(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Boolean;

    invoke-virtual {v0}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v0

    return v0
.end method

.method public static isUnsafeFound()Z
    .locals 1

    .prologue
    .line 58
    sget-boolean v0, Lorg/jboss/netty/util/UnsafeDetectUtil;->UNSAFE_FOUND:Z

    return v0
.end method

.method public static isUnsafeFound(Ljava/lang/ClassLoader;)Z
    .locals 5
    .parameter "loader"

    .prologue
    const/4 v2, 0x0

    .line 37
    :try_start_0
    const-string v3, "sun.misc.Unsafe"

    const/4 v4, 0x1

    invoke-static {v3, v4, p0}, Ljava/lang/Class;->forName(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;

    move-result-object v1

    .line 38
    .local v1, unsafeClazz:Ljava/lang/Class;,"Ljava/lang/Class<*>;"
    invoke-static {v1}, Lorg/jboss/netty/util/UnsafeDetectUtil;->hasUnsafeField(Ljava/lang/Class;)Z
    :try_end_0
    .catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/SecurityException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/security/PrivilegedActionException; {:try_start_0 .. :try_end_0} :catch_2

    move-result v2

    .line 44
    .end local v1           #unsafeClazz:Ljava/lang/Class;,"Ljava/lang/Class<*>;"
    :goto_0
    return v2

    .line 39
    :catch_0
    move-exception v0

    .line 40
    .local v0, e:Ljava/lang/ClassNotFoundException;
    goto :goto_0

    .line 41
    .end local v0           #e:Ljava/lang/ClassNotFoundException;
    :catch_1
    move-exception v0

    .line 42
    .local v0, e:Ljava/lang/SecurityException;
    goto :goto_0

    .line 43
    .end local v0           #e:Ljava/lang/SecurityException;
    :catch_2
    move-exception v0

    .line 44
    .local v0, e:Ljava/security/PrivilegedActionException;
    goto :goto_0
.end method
